package com.bw.message.adapter

import android.widget.BaseAdapter
import com.bumptech.glide.Glide
import com.bw.message.R
import com.bw.message.databinding.ItemMessageBinding
import com.bw.message.entity.MessageData
import com.bw.message.entity.MessageEntity
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class MessageAdapter : BaseQuickAdapter<MessageData, BaseViewHolder>(R.layout.item_message){
    override fun convert(holder: BaseViewHolder, item: MessageData) {
        holder.apply {
            setText(R.id.message_tv_name , item.messageType)
            setText(R.id.message_tv_desc , item.messageContent)
            setText(R.id.message_tv_time , item.sendTime)
            setText(R.id.message_tv_status , item.messageStatus)

            if (item.messageStatus == "已读"){
                setText(R.id.message_tv_status ,"已读")
                setBackgroundResource(R.id.message_tv_status,R.drawable.text_bg)
            }else if (item.messageStatus == "处理中"){
                setText(R.id.message_tv_status ,"处理中")
                setBackgroundResource(R.id.message_tv_status,R.drawable.text_bg1)
            }else  if (item.messageStatus == "已过期"){
                setText(R.id.message_tv_status ,"已过期")
                setBackgroundResource(R.id.message_tv_status,R.drawable.text_bg2)
            }

            if (item.messageType == "车位管理"){
                Glide.with(holder.itemView).load(R.drawable.item_message_img3).into(holder.getView(R.id.message_img))
            }else if (item.messageType == "系统通知"){
                Glide.with(holder.itemView).load(R.drawable.item_message_img).into(holder.getView(R.id.message_img))
            }else  if (item.messageType == "物业服务"){
                Glide.with(holder.itemView).load(R.drawable.item_message_img2).into(holder.getView(R.id.message_img))
            }
        }

    }


}